from typing import List


# O(N)

class Solution:
    def maximumPopulation(self, logs: List[List[int]]) -> int:
        count = [0] * 101
        for birth, death in logs:
            count[birth - 1950] += 1
            count[death - 1950] -= 1

        ans_year, ans_num = 0, 0
        now = 0
        for i in range(101):
            now += count[i]
            if now > ans_num:
                ans_year = i + 1950
                ans_num = now

        return ans_year


if __name__ == "__main__":
    print(Solution().maximumPopulation([[1993, 1999], [2000, 2010]]))  # 1993
    print(Solution().maximumPopulation([[1950, 1961], [1960, 1971], [1970, 1981]]))  # 1960

    # 自制用例
    print(Solution().maximumPopulation([[1950, 1960], [1960, 1971]]))  # 1950
